package DemoFTP;
import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;

public class FtpConnectDemo {
    public static void main(String[] args) {
        FTPClient client = new FTPClient();

        try {
            client.connect("192.168.1.10");

            //
            // When login success the login method returns true.
            //
            boolean login = client.login("a", "123456");

            if (login) {
                System.out.println("Dang nhap thanh cong...");

                //
                // When logout success the logout method returns true.
                //
                boolean logout = client.logout();
                if (logout) {
                    System.out.println("Da Logout khoi FTP Server...");
                }
            } else {
                System.out.println("Dang nhap that bai...");
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                //
                // Closes the connection to the FTP server
                //
                client.disconnect();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
